import 'package:flutter/cupertino.dart';
import 'package:tencent_cloud_chat_uikit/czm_custom_widget/widget_builder_type_def.dart';

/// 创作猫组件Builder桥接，用于需要用到UIKit内部的Model业务但组件又需要自定义时使用
class CZMWidgetBuilderBridge {
  CZMWidgetBuilderBridge._internal();

  static CZMWidgetBuilderBridge getInstance() {
    _instance ??= CZMWidgetBuilderBridge._internal();
    return _instance!;
  }

  static CZMWidgetBuilderBridge? _instance;

  /// 注册自定义组件Builder
  /// 注册组件位置在主项目的 lib/app/modules/im/utils/custom_widget_bridge.dart:11
  void registerWidgetBuilder({
    required WidgetBuilder appBarLeadingIconBuilder,
    required ForwardMessageConfirmWidgetBuilder forwardMessageConfirmWidgetBuilder,
    required MSDialogBuilder msDialogBuilder,
    required ShowToastBuilder showToastBuilder,
    required ToForwardMessagePage toForwardMessagePage,
    required ToAtMessagePage toAtMessagePage,
    required UserTagBuilder userTagBuilder,
    required GroupNoticeBar groupNoticeBar,
    required ForbiddenInputBuilder forbiddenInputBuilder,
    required MessageReadReceiptPage messageReadReceiptPage,
  }) {
    _appBarLeadingIcon = appBarLeadingIconBuilder;
    _forwardMessageConfirmWidget = forwardMessageConfirmWidgetBuilder;
    _msDialog = msDialogBuilder;
    _showToast = showToastBuilder;
    _toForwardMessagePage = toForwardMessagePage;
    _toAtMessagePage = toAtMessagePage;
    _userTag = userTagBuilder;
    _groupNoticeBar = groupNoticeBar;
    _forbiddenInputBuilder = forbiddenInputBuilder;
    _messageReadReceiptPage = messageReadReceiptPage;
  }

  /// 二次确认弹窗
  MSDialogBuilder get msDialog => _msDialog;
  late MSDialogBuilder _msDialog;

  /// appBar返回按钮
  WidgetBuilder get appBarLeadingIcon => _appBarLeadingIcon;
  late WidgetBuilder _appBarLeadingIcon;

  /// 转发消息二次确认弹窗
  ForwardMessageConfirmWidgetBuilder get forwardMessageConfirmWidget => _forwardMessageConfirmWidget;
  late ForwardMessageConfirmWidgetBuilder _forwardMessageConfirmWidget;

  /// 显示Toast
  ShowToastBuilder get showToast => _showToast;
  late ShowToastBuilder _showToast;

  /// 跳转转发消息页面
  ToForwardMessagePage get toForwardMessagePage => _toForwardMessagePage;
  late ToForwardMessagePage _toForwardMessagePage;

  ToAtMessagePage get toAtMessagePage => _toAtMessagePage;
  late ToAtMessagePage _toAtMessagePage;

  /// 用户标签
  UserTagBuilder get userTag => _userTag;
  late UserTagBuilder _userTag;

  /// 群公告
  GroupNoticeBar get groupNoticeBar => _groupNoticeBar;
  late GroupNoticeBar _groupNoticeBar;

  /// 禁止输入框
  ForbiddenInputBuilder get forbiddenInputBuilder => _forbiddenInputBuilder;
  late ForbiddenInputBuilder _forbiddenInputBuilder;

  /// 消息已读详情页
  MessageReadReceiptPage get messageReadReceiptPage => _messageReadReceiptPage;
  late MessageReadReceiptPage _messageReadReceiptPage;
}
